import {Injectable} from "@angular/core";
import {Observable} from "rxjs/Observable";
import {Account} from "../models/account";
import {MsgResult} from "../models/msg-result";
import {API} from "../constants/constants";
import {RequestUtil} from "../util/request-util";

@Injectable()
export class AuthService {
  redirectUrl : string;

  constructor(
      private requestUtil:RequestUtil
  ) { }

  login(account: Account){
    let accountName = account.accountName;
    let password = account.password;
    return this.requestUtil.post(API.loginURl,"accountName=" + accountName + "&password=" + password);
  }

  logout(): Observable<MsgResult> {
    return this.requestUtil.post(API.logout);
  }
}
